#include "card.h"
#include "pack.h"

Card::Card(Byte v): value(v)
{

}

Card::Card(const Byte& s, const Byte& r): value((s*13)+r)
{

}

Byte Card::getSuit() const
{
	return value/13;
}

Byte Card::getRank() const
{
	return value%13;
}



String Card::toString(const Byte& s, const Byte& r)
{
	return Card(s, r).toString();
}


String Card::toString() const
{
	StringStream			str;
	const Byte&				suite		=getSuit();
	const Byte&				rank		=getRank();
	static const Char		suites[]	={'c', 'd', 'h', 's'};
	static const Char		highCards[]	={'J', 'Q', 'K', 'A'};

	if (rank>=9)
	{
		str << highCards[rank-9];
	} else
	{
		str << (Uint32)(rank+2);
	}

	str << suites[suite];

	return str.str();
}

Bool Card::operator==(const Card& c) const
{
	return value==c.value;
}

Bool Card::operator<(const Card& c) const
{
	return value<c.value;
}